package cn.hxzy.zyicon.entity.vo;

import lombok.Data;

@Data
public class ReturnBean {
    private Integer code;
    private String msg;
    private Object data;
    private ReturnBean(Integer code,String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;

    }

    private ReturnBean() {
    }

    public static ReturnBean of(AnswerCode answerCode, Object obj) {
        return new ReturnBean(answerCode.code,answerCode.msg,obj);
    }
    public static ReturnBean of(AnswerCode answerCode) {
        return new ReturnBean(answerCode.code,answerCode.msg, null);
    }
    public enum AnswerCode {

        SUCCESS("操作成功", 200),
        UNKNOWN_ERROR("未知错误", 500),
        PARAMETER_ERROR("参数错误", 400),
        NOT_LOGIN("未登录", 401),
        AUTH_ERROR("账号或密码错误", 410),
        verify_ERROR("验证码错误", 410),
        ADD_ERROR("添加出错", 402),
        NOT_PERMISSION("服务器已拒绝", 403),
        OBJECT_NOT_EXIST("对象不存在", 404),
        METHOD_NOT_SUPPORTED("方法不被支持", 405),
        UPDATE_ERROR("修改出错", 406),
        DELETE_ERROR("删除出错", 407);

        private Integer code;
        private String msg;

        AnswerCode(String msg, Integer code) {
            this.msg = msg;
            this.code = code;
        }
    }
}
